package com.web;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;

@WebServlet(urlPatterns = "/WebHomework")
public class WebHomework extends HttpServlet {
    /**
     * 编写表单，提交给Servlet，并在servlet中能够去对应的数据
     */
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("接收到");
        String username = req.getParameter("username");
        String age = req.getParameter("age");
        String telephone = req.getParameter("telephone");
        String address = req.getParameter("address");
        String sex = req.getParameter("sex");
        String[] likes = req.getParameterValues("like");





        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().write(username);
        resp.getWriter().write(age);
        resp.getWriter().write(telephone);
        resp.getWriter().write(address);
        resp.getWriter().write(sex);
        resp.getWriter().write(Arrays.toString(likes));
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
